package com.todaynews.ui.video.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.todaynews.ui.video.VideosListFragment;
import com.todaynews.ui.video.model.VideoChannel;
import java.util.ArrayList;
import java.util.List;

/**
 * @description: 频道的adapter
 */

public class VideoChannelPagerAdapter extends FragmentStatePagerAdapter {

    private List<VideoChannel> channels;

    public VideoChannelPagerAdapter(List<VideoChannel> channelList, FragmentManager fm) {
        super(fm);
        channels = channelList != null ? channelList : new ArrayList<>();
    }

    @Override
    public Fragment getItem(int position) {
        return VideosListFragment.newInstance(channels.get(position).getCode());
    }

    @Override
    public int getCount() {
        return channels.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return channels.get(position).getTitle();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}